package com.bookstore.model.entity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="BOOKS")
public class Book {
	
	private long bookId;
	private String isbn;
	private String name;
	private Date publishDate;
	private BigDecimal price;
	private Set<Chapter> chapters = new HashSet<Chapter>();	

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	@Column(name="BOOK_ID")
	public long getId() {
		return bookId;
	}
	
	public void setId(long id) {
		this.bookId = id;
	}
	
	@Column(name="BOOK_ISBN")
	public String getIsbn() {
		return isbn;
	}	
	
	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}
	
	@Column(name="BOOK_NAME")
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="BOOK_PUBLISH_DATE")
	@Temporal(TemporalType.DATE)
	public Date getPublishDate() {
		return publishDate;
	}
	
	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}	

	@Column(name="BOOK_PRICE")
	public BigDecimal getPrice() {
		return price;
	}
	
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	

	@OneToMany
	public Set<Chapter> getChapters() {
		return chapters;
	}
	
	public void setChapters(Set<Chapter> chapters) {
		this.chapters = chapters;
	}	

}
